import pandas as pd
from bokeh.colors.groups import orange
from matplotlib import pyplot as plt
import  matplotlib.ticker as ticker
from matplotlib.lines import lineStyles

plt.rcParams['font.sans-serif']=['SimHei']
job_salary=[]
job_list=["人工智能","前端","图像","安卓","算法","软件","Android","Java","运维",'数据']
for job in job_list:
    data = pd.read_excel(f"./data4_3_classify_job/{job}.xlsx")
    data1=data.drop('Unnamed: 0',axis=1)
    salary_average = int(data1['salary'].mean())
    job_salary.append(salary_average)
data_new = pd.DataFrame({'岗位名称':job_list,
                         '平均工资':job_salary})
data_new = data_new.sort_values(by='平均工资',ascending=False)
data_new = data_new.reset_index(drop=True)
average_1=data_new['平均工资'].mean()
data_new.plot(kind='line',x='岗位名称',y='平均工资',color='red',marker='o',linestyle='-',markersize=5,markeredgecolor='red',
              markerfacecolor='red')
average_salary=data_new['平均工资'].tolist()
for x,y in enumerate(average_salary):
    plt.text(x,y,y,ha='center',fontsize=12)
plt.plot([0,9],[average_1,average_1],color='b',linewidth=2)
plt.text(6,average_1+100,'平均值：',fontsize=11,color='b')
plt.ylim(8000,19000)
plt.title('罗坛作业：各岗位平均工资排序')
plt.xlabel('岗位名称',fontsize=16)
plt.ylabel('平均工资',fontsize=16)
plt.xticks(range(len(job_list)),job_list,fontsize=10,rotation=0)
plt.tight_layout()
plt.savefig('./picture/5-4.各种岗位平均工资排序.png')
plt.show()



